$(function() {
	// body...

	console.log(titleUrl);


    $.ajax({
        url: severUrl+'index.php?m=Web&a=pageList&cate_id='+titleUrl.cate_id,
        type: 'GET',
        dataType: 'JSONP'
    })
    .done(function(data) {
        console.log("success");
        console.log(data);
        articlelistFun(data.list);
        tcdPageCode(data.page.totalPage)
        
    })
    .fail(function() {
        console.log("error");
    })
    .always(function() {
        console.log("complete");
    });







    function tcdPageCode(pageCounts){

        $(".tcdPageCode").createPage({
            pageCount:pageCounts,
            current:1,
            backFn:function(p){
                console.log(p);
                 $.ajax({
                    url: severUrl+'index.php?m=Web&a=pageList&cate_id='+titleUrl.cate_id+'&p='+p,
                    type: 'GET',
                    dataType: 'JSONP'
                })
                .done(function(data) {
                    console.log("success");
                    console.log(data);
                    articlelistFun(data.list);
                    
                })

            }
        });

    }


function articlelistFun(data){
        var dari = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
        var ANNList = $('#ANNList');
        var html = '';

        for (var i = 0; i < data.length; i++) {
            var issueDate = data[i].issueDate
            var nian = (issueDate.split("-"))[0];
            var yue = (issueDate.split("-"))[1];
            var ri = (issueDate.split("-"))[2];


            var cn = '<li class="clearfloat">'+
            ' <div class="timeCom">'+dari[(yue-1)] +' '+ri+', '+nian+'</div>'+
            '<div class="RigCon">'+
            '<a href="article.html?article_id='+data[i].article_id+'">'+
            '<p>'+data[i].title+'</p>'+
            '<span>PRESS RELEASE</span>'+
            '</a>'+
            '</div>'+
            '</li>';
            html+=cn;
        }
        ANNList.html(html);
    }

})